package com.zyht.wechat;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.wx.model.BussinessException;

public class AccessToken {

	private Integer errcode;

	private String errmsg;

	@JSONField(name="access_token")
	private String accessToken;

	@JSONField(name="expires_in")
	private Long expiresIn;

	public Integer getErrcode(){

		return errcode;
	}

	public void setErrcode(Integer errcode){

		this.errcode = errcode;
	}

	public String getErrmsg(){

		return errmsg;
	}

	public void setErrmsg(String errmsg){

		this.errmsg = errmsg;
	}

	public String getAccessToken(){

		return accessToken;
	}

	public void setAccessToken(String accessToken){

		this.accessToken = accessToken;
	}

	public Long getExpiresIn(){

		return expiresIn;
	}

	public void setExpiresIn(Long expiresIn){

		this.expiresIn = expiresIn;
	}
	
	public boolean isOk(){
		return null==errcode;
	}
	
	public final String toJsonString(){
		if(isOk())
			return JSON.toJSONString(this);
		throw new BussinessException("AccessToken获取异常:["+this.errcode+":"+this.errmsg+"]");
	}
}
